package com.example.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.mapper.GejieLinshiMapper;
import com.example.demo.model.GejieLinshi;
import com.example.demo.service.MQSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.UUID;


@RestController
public class WebPageController {

    @Autowired
    GejieLinshiMapper gejieLinshiMapper;

    @Autowired
    MQSender mqSender;


    @RequestMapping("/test")
    public String test() {
        QueryWrapper wrapper = new QueryWrapper<GejieLinshi>();
        wrapper.last(" limit 1");
        List<GejieLinshi> l = gejieLinshiMapper.selectList(wrapper);
        return "";
    }

    @RequestMapping("/testFile")
    public String createZip(int num) {
        String code = UUID.randomUUID().toString().replace("-", "");
        System.out.println("生成code:" + code);
        return "success";
    }

    @RequestMapping("/testjedis")
    public String jedisTest(int num) {
        try {
            Jedis jedis = new Jedis("101.201.155.20", 7001);
            jedis.set("sss", "sdfsdf");
        } catch (Exception e) {
            return e.getMessage();
        }
        return "";
    }

    @RequestMapping("/testmq")
    public String jedisMq() {
        try {
            mqSender.send("zhanglifeng_test");
        } catch (Exception e) {
            return e.getMessage();
        }
        return "";
    }
}




